package config_manager

import (
	"go_server/game_server/dataconfig/configpb"
	"go_server/zinx/zlog"
)

// 获取单个任务的数据
func GetStcTableTask_SheetTaskById(id int32) (configpb.StcTableTask_SheetTask_27074BFE, bool) {
	config, ok := tableTaskSheetTask[id]
	if !ok {
		zlog.Errorf("GetStcTableTask_SheetTask Err!!! id: %d", id)
		return configpb.StcTableTask_SheetTask_27074BFE{}, false
	}

	return configpb.StcTableTask_SheetTask_27074BFE{
		Id:             config.Id,
		Type:           config.Type,
		Condition:      config.Condition,
		Value:          config.Value,
		Count:          config.Count,
		PrereQuisites:  config.PrereQuisites,
		TaskReward:     config.TaskReward,
		Chapter:        config.Chapter,
		ChapterReward:  config.ChapterReward,
		ActivityReward: config.ActivityReward,
	}, true
}

// 根据任务类型 批量获取任务的数据
func GetStcTableTask_SheetTaskListByType(tastType int32) map[int32]*configpb.StcTableTask_SheetTask_27074BFE {
	allConfig := make(map[int32]*configpb.StcTableTask_SheetTask_27074BFE)

	if tableTaskSheetTask != nil {
		for _, config := range tableTaskSheetTask {
			if tastType == config.Type { //根据 任务类别 分组
				row := configpb.StcTableTask_SheetTask_27074BFE{
					Id:             config.Id,
					Type:           config.Type,
					Condition:      config.Condition,
					Value:          config.Value,
					Count:          config.Count,
					PrereQuisites:  config.PrereQuisites,
					TaskReward:     config.TaskReward,
					Chapter:        config.Chapter,
					ChapterReward:  config.ChapterReward,
					ActivityReward: config.ActivityReward,
				}
				allConfig[config.Id] = &row
			}
		}
	}
	return allConfig
}

// 根据任务类型、任务事件 获取批量任务的数据
func GetStcTableTask_SheetTaskListByEvent(tastType int32, tastEvent int32) map[int32]*configpb.StcTableTask_SheetTask_27074BFE {
	allConfig := make(map[int32]*configpb.StcTableTask_SheetTask_27074BFE)

	if tableTaskSheetTask != nil {
		for _, config := range tableTaskSheetTask {
			if tastType == config.Type && tastEvent == config.Condition { //根据 任务类别-任务事件 分组
				row := configpb.StcTableTask_SheetTask_27074BFE{
					Id:             config.Id,
					Type:           config.Type,
					Condition:      config.Condition,
					Value:          config.Value,
					Count:          config.Count,
					PrereQuisites:  config.PrereQuisites,
					TaskReward:     config.TaskReward,
					Chapter:        config.Chapter,
					ChapterReward:  config.ChapterReward,
					ActivityReward: config.ActivityReward,
				}
				allConfig[config.Id] = &row
			}
		}
	}
	return allConfig
}

// 根据任务类型、任务事件、任务章节 获取单条章节奖励任务的数据 (只针对主线任务进行读取)
func GetStcTableTask_SheetTaskInfoByChapter(tastType int32, tastEvent int32, Chapter int32) *configpb.StcTableTask_SheetTask_27074BFE {
	var config *configpb.StcTableTask_SheetTask_27074BFE

	if tableTaskSheetTask != nil {
		for _, val := range tableTaskSheetTask {
			if tastType == val.Type && tastEvent == val.Condition && Chapter == val.Chapter { //根据 任务类别-任务事件-任务所属章节 分组
				row := configpb.StcTableTask_SheetTask_27074BFE{
					Id:             val.Id,
					Type:           val.Type,
					Condition:      val.Condition,
					Value:          val.Value,
					Count:          val.Count,
					PrereQuisites:  val.PrereQuisites,
					TaskReward:     val.TaskReward,
					Chapter:        val.Chapter,
					ChapterReward:  val.ChapterReward,
					ActivityReward: val.ActivityReward,
				}
				config = &row
			}
		}
	}
	return config
}

// 根据任务类型、任务章节 获取当前章节下的所有任务配置数据 (只针对主线任务进行读取)
func GetStcTableTask_SheetTaskListByChapter(tastType int32, Chapter int32) map[int32]*configpb.StcTableTask_SheetTask_27074BFE {
	allConfig := make(map[int32]*configpb.StcTableTask_SheetTask_27074BFE)

	if tableTaskSheetTask != nil {
		for _, config := range tableTaskSheetTask {
			if tastType == config.Type && Chapter == config.Chapter { //根据 任务类别-任务事件-任务所属章节 分组
				row := configpb.StcTableTask_SheetTask_27074BFE{
					Id:             config.Id,
					Type:           config.Type,
					Condition:      config.Condition,
					Value:          config.Value,
					Count:          config.Count,
					PrereQuisites:  config.PrereQuisites,
					TaskReward:     config.TaskReward,
					Chapter:        config.Chapter,
					ChapterReward:  config.ChapterReward,
					ActivityReward: config.ActivityReward,
				}
				allConfig[config.Id] = &row
			}
		}
	}
	return allConfig
}

// 获取单个进度宝箱配置数据
func GetStcTableActivityConfig_SheetActivityConfigById(id int32) (configpb.StcTable_ActivityConfig_Sheet_ActivityConfig_805A3166, bool) {
	config, ok := tableActivityConfigSheetActivityConfig[id]
	if !ok {
		zlog.Errorf("GetStcTableTask_SheetTask Err!!! id: %d", id)
		return configpb.StcTable_ActivityConfig_Sheet_ActivityConfig_805A3166{}, false
	}

	return configpb.StcTable_ActivityConfig_Sheet_ActivityConfig_805A3166{
		Id:     config.Id,
		Value:  config.Value,
		Reward: config.Reward,
	}, true
}

// 获取宝箱配置列表数据
func GetStcTableActivityConfig_SheetActivityConfigList() map[int32]*configpb.StcTable_ActivityConfig_Sheet_ActivityConfig_805A3166 {
	allConfig := make(map[int32]*configpb.StcTable_ActivityConfig_Sheet_ActivityConfig_805A3166)

	if tableActivityConfigSheetActivityConfig != nil {
		for _, config := range tableActivityConfigSheetActivityConfig {
			row := configpb.StcTable_ActivityConfig_Sheet_ActivityConfig_805A3166{
				Id:     config.Id,
				Value:  config.Value,
				Reward: config.Reward,
			}
			allConfig[config.Id] = &row
		}
	}
	return allConfig
}

// 获取成长、支线任务的数据
func GetStcTableTask_SheetTaskListByTwoType(tastType1 int32, tastType2 int32) map[int32]*configpb.StcTableTask_SheetTask_27074BFE {
	allConfig := make(map[int32]*configpb.StcTableTask_SheetTask_27074BFE)

	if tableTaskSheetTask != nil {
		for _, config := range tableTaskSheetTask {
			if tastType1 == config.Type || tastType2 == config.Type { //根据 任务类别 分组
				row := configpb.StcTableTask_SheetTask_27074BFE{
					Id:             config.Id,
					Type:           config.Type,
					Condition:      config.Condition,
					Value:          config.Value,
					Count:          config.Count,
					PrereQuisites:  config.PrereQuisites,
					TaskReward:     config.TaskReward,
					Chapter:        config.Chapter,
					ChapterReward:  config.ChapterReward,
					ActivityReward: config.ActivityReward,
				}
				allConfig[config.Id] = &row
			}
		}
	}
	return allConfig
}
